var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function a() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((a.prototype = i.prototype), new a()));
      };
    })(),
  EmailDetailDialog = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.listArr = []),
        (t.fujian_data = []),
        (t.emailid = ""),
        (t.isMust = !1),
        (t.onLoadEmailDetailDataFn = {
          caller: t,
          code: 1185,
          method: function (e) {
            if (0 == e.code) {
              (t.email_detail_name.text = e.data.name),
                (t.email_detail_time.text = e.data.createTime),
                (t.email_detail_content.text = e.data.content),
                e.data.list.length > 0 && (t.list_emailDetaill.visible = !0);
              var i;
              (t.fujian_data = []),
                (t.listArr = []),
                (t.fujian_data = e.data.list);
              for (var a = 0; a < t.fujian_data.length; a++)
                (i = {
                  emailDetail_lable: {
                    text:
                      t.fujian_data[a].name +
                      "(" +
                      t.fujian_data[a].num +
                      "个)",
                  },
                  email_tiqu_money: {
                    text: t.dealTiQuMoney(t.fujian_data[a].money),
                  },
                  email_tiqu_button: { label: "提取" },
                  email_tiqu_status: {
                    text: t.dealEmailFuJiangState(t.fujian_data[a].state),
                  },
                  name: t.fujian_data[a].name,
                  thingid: t.fujian_data[a].thingid,
                  thingtype: t.fujian_data[a].thingtype,
                }),
                  t.listArr.push(i);
              t.list_emailDetaill.dataSource = t.listArr;
            } else ToastView.toastView(e.msg);
          },
        }),
        (t.onLoadEmailTiQuConDataFn = {
          caller: t,
          code: 1186,
          method: function (e) {
            0 === e.code &&
              ("send_email_type" == t.email_type
                ? WebSocketService.send({ c: 1185, d: { id: t.emailid, t: 2 } })
                : "receiver_email_type" == t.email_type &&
                  WebSocketService.send({
                    c: 1185,
                    d: { id: t.emailid, t: 1 },
                  }));
          },
        }),
        WebSocketService.addListener(t.onLoadEmailDetailDataFn, !0),
        WebSocketService.addListener(t.onLoadEmailTiQuConDataFn, !0),
        WebSocketService.addListener({
          caller: t,
          code: 2171,
          method: t.onLoadEmailOperation,
        }),
        t.list_emailDetaill.on(Laya.Event.CLICK, t, t.onActionTiQuFn),
        (t.list_emailDetaill.selectEnable = !0),
        (t.list_emailDetaill.renderHandler = new Laya.Handler(
          t,
          t.UpdateEmailDetailRender
        )),
        (t.list_emailDetaill.vScrollBarSkin = ""),
        t.btn_email_detail_cancle.on(
          Laya.Event.CLICK,
          t,
          t.onEmailDetailCancleAction
        ),
        t.btn_deleteEmail.on(Laya.Event.CLICK, t, t.onDeleteEmailDidClick),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showEmailDetail = function (e, i) {
        null == this.emailDetail &&
          ((this.emailDetail = new t()), (this.emailDetail.zOrder = 1e3)),
          this.emailDetail.popup(!0),
          (this.emailDetail.email_type = i),
          (this.emailDetail.emailid = e),
          "send_email_type" == i
            ? (WebSocketService.send({ c: 1185, d: { id: e, t: 2 } }),
              (this.emailDetail.label_email_toFrom.text = "收件人"))
            : "receiver_email_type" == i &&
              (WebSocketService.send({ c: 1185, d: { id: e, t: 1 } }),
              (this.emailDetail.label_email_toFrom.text = "发件人")),
          (this.emailDetail.list_emailDetaill.visible = !1),
          (this.emailDetail.isMust = !0);
      }),
      (t.prototype.UpdateEmailDetailRender = function (e, t) {
        if (!(t > this.listArr.length)) {
          var i = e.getChildByName("email_tiqu_status"),
            a = e.getChildByName("email_tiqu_button");
          "send_email_type" == this.email_type
            ? ((a.visible = !1), (i.visible = !0))
            : "1" == this.fujian_data[t].state
            ? ((a.visible = !1), (i.visible = !0))
            : ((a.visible = !0), (i.visible = !1));
        }
      }),
      (t.prototype.dealTiQuMoney = function (e) {
        return e > 0 ? "需银币:" + e + "银" : "";
      }),
      (t.prototype.dealEmailFuJiangState = function (e) {
        return "0" == e ? "未领取" : "已领取";
      }),
      (t.prototype.onActionTiQuFn = function (e) {
        if ("" != e.target.name)
          if ("email_tiqu_button" == e.target.name) {
            var t = this.list_emailDetaill.selectedIndex,
              i = this.fujian_data[t].thingid,
              a = this.fujian_data[t].thingtype;
            WebSocketService.send({
              c: 1186,
              d: { id: this.emailid, tid: i, t: a },
            });
          } else {
            var l = this.list_emailDetaill.selectedItem,
              n = { thingid: l.thingid, thingtype: l.thingtype, name: l.name },
              t = this.list_emailDetaill.selectedIndex,
              o = {
                pawnId: (i = this.fujian_data[t].thingid),
                money: "",
                data: l,
                type: 0,
                id: i,
              };
            3 == (a = this.fujian_data[t].thingtype)
              ? LookFuJiangView.showHeroDetailDialog(o)
              : LookDetailView.showLookDetailView(n);
          }
      }),
      (t.prototype.onLoadEmailOperation = function (e) {
        0 == e.code
          ? (ToastView.toastView("删除成功"),
            "send_email_type" == this.email_type
              ? WebSocketService.send({ c: 1171, d: { type: "2", pageNum: 0 } })
              : WebSocketService.send({
                  c: 1171,
                  d: { type: "1", pageNum: 0 },
                }))
          : ToastView.toastView(e.msg);
      }),
      (t.prototype.onDeleteEmailDidClick = function () {
        NormalDialog.showNormalDialog(
          "您确认要删除此邮件吗？",
          this,
          this.okMethodFuntion
        );
      }),
      (t.prototype.okMethodFuntion = function () {
        WebSocketService.send({ c: 2171, d: { id: this.emailid } });
      }),
      (t.prototype.onEmailDetailCancleAction = function () {
        this.close("ok");
      }),
      (t.prototype.close = function (t) {
        ("side" == t && this.isMust) ||
          (this.isMust && (this.isMust = !1), e.prototype.close.call(this, t));
      }),
      t
    );
  })(ui.EmailController.EmailDetailDialogUI);
